<template>
	<view class="conter">
		<header-box :title="'往来单位'"></header-box>


		<view class="recording mt40" style="padding-left: 31rpx;">
			<view class="flex f32">
				<text class="flex-direction flex a" :class="sts == 0 ? 'style' : ''" @tap="flg(0)">供应商</text>
				<text class="flex-direction flex" :class="sts == 1 ? 'style' : ''" @tap="flg(1)">客户</text>
			</view>
		</view>


		<!-- 供应商 -->
		<view class="text-tab" v-if="sts == 0">
			<view class="box">
				<view class="marige-bor" v-for="(item, index) in textList" :key="index" @tap="skip(item)">
					<view class="diso-flex mb30">
						<text>{{item.supplier_name}}</text>
					</view>
					<view class="flex justify-between" style="color: #4D4D4D; ">
						<view class="">
							<text>联系人：</text> {{item.person_name}}
						</view>
						<text>电话: {{item.phone}}</text>
					</view>
				</view>
			</view>
		</view>
		
		<!-- 客户 -->
		<view class="text-tab" v-if="sts == 1">
			<view class="box">
				<view class="marige-bor" v-for="(item, index) in textList" :key="index" @tap="skip(item)">
					
					<view class="diso-flex mb30">
						<text>{{item.name}}</text>
					</view>
					<view class="flex justify-between" style="color: #4D4D4D; ">
						<view class="">
							<text>联系人：</text> {{item.person_name}}
						</view>
						<text>电话: {{item.phone}}</text>
					</view>
				</view>
			</view>
		</view>


		<!-- <view @tap="$tools.to('/pages/contact/individual')" class="add">
			<image class="w100 h100" src="../../static/index/add.png" mode=""></image>
		</view> -->

		<view class="flex-box total">
			<view class="">
				合计：
			</view>
			<view class="">
				{{textList.length}} 个
			</view>
		</view>

	</view>
</template>

<script>
	import headerBox from '../../components/header/header.vue'

	export default {
		components: {
			headerBox
		},
		data() {
			return {
				title: '供应商',
				textList: [],
				addUrl: '',
				total: 0,
				list: [{
					name: '供应商'
				}, {
					name: '客户'
				}],
				current: 0,
				sts: 0,
				page: 1,
			}
		},
		onLoad() {
			
		},
		onShow() {
			if (this.sts == 0 ) {
				this.textList = []
				this.stockList()
			} else {
				this.getStockList()
			}
			
			
			
		},
		onReachBottom() {
			if (e == 0 ) {
				this.page++
				this.stockList()
			} else {
				this.page++
				this.getStockList()
			}
			
		},
		methods: {
			change(index) {
				this.current = index;
			},

			flg(e) {
				this.sts = e;
				this.textList = []
				if (e == 0 ) {
					this.stockList()
				} else {
					this.getStockList()
				}
			},

			async stockList() {
				const res = await this.$u.post("api/Invoic/supplier_find",{
					page: this.page,
					pagesize: 20,
				});
				this.textList = res.data
				this.total = this.textList.length
				console.log(res, this.total, '444444444')
			},
			
			async getStockList() {
				const res = await this.$u.post("api/Invoic/wldw_find",{
					page: this.page,
					pagesize: 20,
				});
				this.textList = res.data
				this.total = this.textList.length
			},

			skip(item) {
				// console.log('跳转的路劲', item)
				// uni.navigateTo({
				// 	url: '/pages/contact/remove?item=' + item.id
				// });
			},

		}
	}
</script>

<style lang="scss" scoped>
	.conter {
		width: 100%;
		height: 100%;
		position: relative;

		.recording {
			.a {
				width: 140rpx;
			}

			.style {
				color: #6268E4;
			}

			.style::after {
				content: '';
				width: 50rpx;
				height: 6rpx;
				color: #6268E4;
				background: #6268E4;
				border-radius: 6rpx;
				margin-top: 15rpx;
			}
		}

		.text-tab {
			width: 100%;
			// padding: 30rpx;/*  */
			padding-bottom: 0;


			.box {
				width: 100%;
				border-radius: 10rpx;
				margin: 0 auto 10rpx;
			}

			.marige-bor {
				width: 90%;
				margin: 10rpx auto;
				color: #333333;
				font-size: 28rpx;
				padding: 40rpx 31rpx;
				border-radius: 10rpx;
				background-color: #FFFFFF;

				.diso-flex {
					width: 100%;
					// height: 80rpx;
					font-size: 30rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #1A1A1A;
					background-color: #FFFFFF;
					// display: flex;
					// align-items: center;
					// justify-content: space-between;
				}

				.conter-image {
					width: 22rpx;
					height: 36rpx;
				}
			}

			.marige-bor:last-child {
				border-bottom: 0;
			}
		}

		// 加号
		.add {
			position: fixed;
			bottom: 200rpx;
			right: 40rpx;
			width: 100rpx;
			height: 100rpx;
			text-align: center;
			line-height: 100rpx;
			border-radius: 50%;
			font-size: 100rpx;
			color: #FFFFFF;
		}

		.total {
			width: 100%;
			position: fixed;
			bottom: 0;
			left: 0;
			height: 100rpx;
			padding: 0 60rpx 0 30rpx;
			background-color: #FFFFFF;
		}

	}
</style>
